#include<bits/stdc++.h>
using namespace std;
int a[1000];
int c[1000];
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    if(a[n]!=a[n-1]) c[n]=0;
    else if(a[n]=a[n-1]) c[n]=a[n];
         else c[n]=0;
    int sum;
    for(int i=1;;i++)
        sum=c[n]+c[n+1];
    cout<<sum;
    return 0;
}
